package cn.fjsay.java.demo2;

public class Test {
    static void u(Monster b) {
        b.menace();
    }

    static void v(DangerousMonster d) {
        d.menace();
        d.destroy();
    }

    static void w(Lethal l) {
        l.kill();
    }

    public static void main(String[] args) {
        Monster monster = new Monster() {
            @Override
            public void menace() {
                System.out.println("普通怪物出现");
            }
        };

        DangerousMonster dangerousMonster = new DangerousMonster() {
            @Override
            public void menace() {
                System.out.println("危险的怪物出现");
            }

            @Override
            public void destroy() {
                System.out.println("危险的怪物开始破坏");
            }
        };

        Lethal lethal = new Lethal() {
            @Override
            public void kill() {
                System.out.println("致命攻击发生");
            }
        };

        u(monster);
        v(dangerousMonster);
        w(lethal);
    }
}